<?php

namespace app\index\controller;

use think\Controller;
use think\Request as RequestAlias;
use think\Db;
use think\Session;
use think\Cache;
use think\Cookie;

/**
 * 前台基础控制器（精简版 - 已移除Web模型依赖）
 */
class Base extends Controller
{
    //自动切换 手机/PC
    public function __construct(RequestAlias $request)
    {
        if ($request->isMobile()) {
            // 切换电脑网页
            config('template.view_path', '../source/application/index/view/web/');
        } else {
            // 切换电脑网页
            config('template.view_path', '../source/application/index/view/web/');
        }
        parent::__construct($request);
    }

    //初始化网站信息
    public function _initialize()
    {
        //当前请求网址信息
        $request = request();

        $current['controller'] = $request->controller();
        $current['action'] = $request->action();
        $current['id'] = 0;
        if (!empty($request->only(['id']))) {
            $current['id'] = $request->only(['id'])['id'];
        }
        $this->assign(compact('current'));

        // 精简版：使用默认网站信息，不从数据库读取
        $web = [
            'site_name' => '权限管理系统',
            'site_title' => '精简版权限管理系统',
            'keywords' => '权限管理,角色管理,RBAC',
            'description' => '基于ThinkPHP的精简版权限管理系统',
            'telephone' => '',
            'email' => '',
            'address' => '',
            'icp' => '',
        ];
        
        // 空数据
        $last_article = [];
        $catgory_child = [];
        $category_parent = [];
        $link = [];
        $view_people = 0;
        $today = 0;
       
        // compact是将变量以数组的形式返回
        $this->assign(compact('web', 'link', 'last_article', 'category_parent', 'catgory_child', 'view_people', 'today'));
    }

   // 访问统计功能已禁用
   /*
    public function record_ip($name)
    {
        // 此功能已禁用，因为website_statistics表已删除
    }
   */
}
